using ReflectionStudio.Core.Events;
using System.Data;
namespace WPFExcelReport
{
    public partial class VWBBST
    {
        public void MOVE2KO(DataRow _dwWB, string _LO, string _LB, string _LP, string _RUNID)
        {
            VWBW.NWBBEW(_dwWB, "20", _RUNID);
            if (_dwWB["WBBPACKNR"].ToString() == "0000")
            {
                _dwWB["WBBPACKNR"] = "0001";
            }
            _dwWB["WBBPACKAUTO"] = "J";
            _dwWB["WBBURLB"] = _dwWB["WBBLB"];
            _dwWB["WBBURLP"] = _dwWB["WBBLP"];
            _dwWB["WBBLB"] = _LB;
            _dwWB["WBBURAKZ"] = "N";
            _dwWB["WBBLP"] = _LP;
            _dwWB["WBBALIEFSCH"] = _dwWB["WBBURLIEFSCH"];
            UWB12(_dwWB);
            VWBW.NWBBEW(_dwWB, "21", _RUNID);
            VWBW.NWBBEW(_dwWB, "31", _RUNID);
        }

        public void WZVV(DataRow _dwWB)
        {
            MessageInfo msg = new MessageInfo();
            msg.MSGTYPE = "WBVVT";
            msg.Sender = RUNID;
            msg.ACTION = "WBVVT";
            msg.AUFTYP = _dwWB["WBBAUFTYP"].ToString();
            msg.KRS = _dwWB["WBBAUFKRS"].ToString();
            msg.LFD = _dwWB["WBBAUFLFD"].ToString();
            msg.POS = _dwWB["WBBAUFPOS"].ToString();
            msg.LIEFSCH = _dwWB["WBBALIEFSCH"].ToString();
            msg.LO = _dwWB["WBBLO"].ToString();
            msg.LB = _dwWB["WBBLB"].ToString();
            msg.LP = _dwWB["WBBLP"].ToString();
            msg.STKNR = _dwWB["WBBSTKNR"].ToString();
            msg.P1 = _dwWB["WBBPACKNR"].ToString();
            msg.P2 = _dwWB["WBBISTKLG"].ToString();
            msg.Where = app.User;
            VICC_WFEVENTS.SVWF.CheckEvents("UIMESSAGE", null, "", msg);
        }

        public void VV03()
        {

            IsGetAUF = false;
            CALL = TBMain.Rows.Count;
            foreach (DataRow _dwWB in TBMain.Rows)
            {
                CNOW++;
                if (_dwWB["WBBURLIEFSCH"].ToString() == LIEFSCH)
                    continue;
                _dwWB["WBBFERTKZ"] = "E";
                _dwWB["WBBURLIEFSCH"] = LIEFSCH;
                _dwWB["WBBALIEFSCH"] = _dwWB["WBBURLIEFSCH"];
                _dwWB["WBBAENDBEN"] = app.User;
                _dwWB["WBBAENDDAT"] = date;
                UWB09(_dwWB);
                if (!IsGetAUF)
                {
                    PM["KRS"] = _dwWB["WBBAUFKRS"].ToString(); ;
                    PM["LFD"] = _dwWB["WBBAUFLFD"].ToString();
                    PM["POS"] = _dwWB["WBBAUFPOS"].ToString();
                    PM["VKPAUF"] = _dwWB["WBBAUFKRS"].ToString() + _dwWB["WBBAUFLFD"].ToString() + _dwWB["WBBAUFPOS"].ToString();
                    PM["ORDERNUM"] = "K" + _dwWB["WBBAUFKRS"].ToString() + _dwWB["WBBAUFLFD"].ToString() + _dwWB["WBBAUFPOS"].ToString();
                    PM["LIEFSCH"] = LIEFSCH;
                    IsGetAUF = true;
                }
            }
            CALL = 0;
            PM["RUNID"] = this.RUNID;
            VVT.VVTCHG(PM);
            VV.VVCHG(PM);
        }

        public void VVTFREE()
        {
            if (WBROWS == null)
                return;
            if (WBROWS.Count == 0)
                return;
            IsGetAUF = false;
            CALL = TBMain.Rows.Count;
            foreach (DataRow row in WBROWS)
            {
                CNOW++;
                filter = "WBBSTKNR='" + row["WBBSTKNR"].ToString() + "'";
                rows = TBMain.Select(filter);
                foreach (DataRow _dwWB in rows)
                {
                    _dwWB["WBBURLIEFSCH"] = "99999999";
                    _dwWB["WBBALIEFSCH"] = _dwWB["WBBURLIEFSCH"];
                    _dwWB["WBBAENDBEN"] = app.User;
                    _dwWB["WBBAENDDAT"] = date;
                    UpdateWBBST(_dwWB, 0);
                    if (!IsGetAUF)
                    {
                        PM["KRS"] = _dwWB["WBBAUFKRS"].ToString(); ;
                        PM["LFD"] = _dwWB["WBBAUFLFD"].ToString();
                        PM["POS"] = _dwWB["WBBAUFPOS"].ToString();
                        PM["VKPAUF"] = _dwWB["WBBAUFKRS"].ToString() + _dwWB["WBBAUFLFD"].ToString() + _dwWB["WBBAUFPOS"].ToString();
                        PM["ORDERNUM"] = "K" + _dwWB["WBBAUFKRS"].ToString() + _dwWB["WBBAUFLFD"].ToString() + _dwWB["WBBAUFPOS"].ToString();
                        PM["LIEFSCH"] = LIEFSCH;
                        IsGetAUF = true;
                    }
                }
            }
            WBROWS = null;
            CALL = 0;
            VVT.VVTCHG(PM);
            VV.VVCHG(PM);
        }
    }
}
